import { findTypeByValue, findTypeByLabel } from '@/utils/findType'
import * as types from "./types"

// 渠道Table
export const configTableFrame = [
  { 
    prop: "num", 
    label: "序号", 
    minWidth: "50px", 
    tooltip: true 
  },
  { 
    prop: "title", 
    label: "标题", 
    minWidth: "150px"
  },
  { 
    prop: "type", 
    label: "类型",
    minWidth: "100px",
    formatter: (row) => {
      return findTypeByValue(row.type, types.questionType);
    }
  },
  {
    prop: "content",
    label: "内容",
    minWidth: "200px",
    formatter: (row) => {
      const content = JSON.parse(row.content.replace(/\n/g, '').replace(/\r/g, ''));
      if(row.type === '0'){
        return content.answer
      }else if(row.type === '1'){
        return content.explain
      }else if(row.type === '2'){
        return row.content
      }
      return row.content;
    }
  },
  {
    prop: "fileUrl",
    label: "文件路径",
    minWidth: "100px"
  },
  {
    prop: "videoUrl",
    label: "视频路径",
    minWidth: "100px"
  },
  { 
    label: "操作", 
    slotName: "operate", 
    fixed: "right",
    minWidth: "150px"
  },
];


export const searchFrame = [
  { 
    label: "问题标题", 
    key: "title", 
    type: 1
  },
  { 
    label: "问题类型", 
    key: "type", 
    type: 2,
    options: types.questionType
  }
]
